% This file was converted from HTML to LaTeX with
% gnuhtml2latex program
% (c) Tomasz Wegrzanowski <maniek@beer.com> 1999
% (c) Gunnar Wolf <gwolf@gwolf.org> 2005-2010
% Version : 0.4.
   \section*{Specification: Mapsforge Binary Map File Format}
   \par 
     \begin{itemize}
       \item 
	 Specification: Mapsforge Binary Map File Format
	 
       
       \begin{itemize}
	 \item 
	   Conceptual design
	   
	 
	 \item 
	   General remarks
	   
	 
	 \item 
	   File structure
	   
	 
	 \item 
	   File header
	   
	 
	 \begin{itemize}
	   \item 
	     Tile index header
	     
	   
	   \item 
	     Tile index entry
	     
	   
	   \item 
	     Tile header
	     
	   
	   \item 
	     POI data
	     
	   
	   \item 
	     Way properties
	     
	   
	   \item 
	     Way data
	     
	   
	 \end{itemize}
	 \item 
	   Version history
	   
	 
       \end{itemize}
     \end{itemize}
   
   \subsection*{Conceptual design}
   \par The
     \textit{mapsforge binary map file format
     } is designed for map rendering on devices with limited resources like mobile phones. It allows for efficient storage of geographical information (e.g. OpenStreetMap data), fast tile-based access, and filtering of map objects by zoom level.
   
   \par The map file consists of several sub-files, each storing the map objects for a different zoom interval. Zoom intervals are non-overlapping groups of consecutive zoom levels. Each zoom interval is represented by a single member of the group, the so-called
     \textit{base zoom level
     }.
   
   \subsection*{General remarks}
   \begin{itemize}
     \item All latitude and longitude coordinates are stored in microdegrees (degrees × 10
       6
       ).
     
     \item Numeric fields with a fixed byte size are stored with
       \textit{Big Endian
       } byte order.
     
     \item Unsigned numeric fields with a variable byte encoding are marked with
       \textit{
	 \texttt{VBE-U
	 } INT
       } and stored as follows:
     
     \begin{itemize}
       \item the first bit of each byte is used for continuation info, the other seven bits for data.
       
       \item the value of the first bit is 1 if the following byte belongs to the field, 0 otherwise.
       
       \item each byte holds seven bits of the numeric value, starting with the least significant ones.
       
     \end{itemize}
     \item Signed numeric fields with a variable byte encoding are marked with
       \textit{
	 \texttt{VBE-S
	 } INT
       } and stored as follows:
     
     \begin{itemize}
       \item the first bit of each byte is used for continuation info, the other six (first byte) or seven (all other bytes) bits for data.
       
       \item the value of the first bit is 1 if the following byte belongs to the field, 0 otherwise.
       
       \item each byte holds six (first byte) or seven (all other bytes) bits of the numeric value, starting with the least significant ones.
       
       \item the second bit in the first byte indicates the sign of the number. A value of 0 means positive, 1 negative.
       
     \end{itemize}
     \item All strings are stored in UTF-8 as follows:
     
     \begin{itemize}
       \item the length
	 \textit{L
	 } of the UTF-8 encoded string in bytes as
	 \textit{
	   \texttt{VBE-U
	   } INT
	 }.
       
       \item 
	 \textit{L
	 } bytes for the UTF-8 encoding of the string.
       
     \end{itemize}
   \end{itemize}
   \subsection*{File structure}
   \par For each zoom interval a so called
     \textit{
       \textbf{sub-file
       }
     } is created. A sub-file consists of a
     \textit{
       \textbf{tile index segment
       }
     } that stores a fixed-size pointer for each tile created in the
     \textit{
       \textbf{tile data segment
       }
     }. The order of storing tiles to the tile data segment and their corresponding pointers to the tile index segment is row-wise and within a row column-wise. Rows and columns are inherently given by the grid layout of the tiles that is defined by the rectangular bounding box. For each tile in the grid, meta information is available in the
     \textit{
       \textbf{tile header
       }
     } accompanied by its payload data (POIs and ways).
   
   \par To read the data of a specific tile in the sub-file, the position of the fixed-size pointer in the index can be computed from the tile coordinates. The index entry points to the offset in the sub-file where the data is stored. Tile coordinates are implicitly given due to the structure of the tile index, thus no tile coordinates need to be stored along each tile.
   
   \begin{verbatim}# meta data
file header

# sub-files
for each sub-file
    # tile index segment
    tile index header
    tile index entries

    # tile data segment
    for each tile
        tile header
        for each POI
            POI data
        for each way
            way properties
     way data
   \end{verbatim}
   \subsection*{File header}
   \includegraphics[width=1\textwidth]{./SpecificationBinaryMapFile/FileHeaderTable-0.eps}
   \includegraphics[width=1\textwidth]{./SpecificationBinaryMapFile/FileHeaderTable-1.eps}

   \subsubsection*{Tile index header}	 
   \includegraphics[width=1\textwidth]{./SpecificationBinaryMapFile/TileIndexHeaderTable.eps}
   
   \subsubsection*{Tile index entry}	        
   \includegraphics[width=1\textwidth]{./SpecificationBinaryMapFile/TileIndexEntryTable.eps}     
   
   \subsubsection*{Tile header}
   \includegraphics[width=1\textwidth]{./SpecificationBinaryMapFile/TileHeaderTable.eps}     
   
   \subsubsection*{POI data}
   \includegraphics[width=1\textwidth]{./SpecificationBinaryMapFile/POIDataTable.eps}     
   
   \subsubsection*{Way properties}
   \includegraphics[width=1\textwidth]{./SpecificationBinaryMapFile/WayPropertiesTable-0.eps}     
   \includegraphics[width=1\textwidth]{./SpecificationBinaryMapFile/WayPropertiesTable-1.eps} 
   
   \subsubsection*{Way data}
   \includegraphics[width=1\textwidth]{./SpecificationBinaryMapFile/WayDataTable.eps}      



 


 
 
 
 
 
 
 
 
 
 


 
 
